using System;

using Pegasus.Diagnostics;

namespace Pegasus.Workflow.Service
{
	/// <summary>
	/// Used to pass information between the workflow and the workflow engine
	/// </summary>
	[Serializable]
	public class WorkflowEventArgs : EventArgs
	{
		// Local Instace Values
		private int m_workflowId = -1;
		private bool m_deliverCurrentState = false;

		/// <summary>
		/// Initializes a new instance of the <see cref="WorkflowEventArgs"/> class.
		/// </summary>
		/// <param name="workflowId">The workflow id.</param>
		/// <param name="deliverToCurrentStateOnly"><c>true</c> if deliver to current state only; otherwise delive to all listeners, <c>false</c>.</param>
		/// <remarks>
		/// When delivering event to the given workflow if deliverToCurrentStateOnly is <c>true</c> then 
		/// the event will only be delivered to listeners/deligates that are on the current state class or
		/// the workflow class.  All other listeners will be ignored.
		/// </remarks>
		public WorkflowEventArgs( int workflowId, bool deliverToCurrentStateOnly )
		{
			// Check Parameters
			ParamCode.AssertRange( workflowId, 1, int.MaxValue, "workflowId" );
			// deliverToCurrentStateOnly is bool

			m_workflowId = workflowId;
			m_deliverCurrentState = deliverToCurrentStateOnly;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="T:WorkflowEventArgs"/> class.
		/// </summary>
		/// <param name="workflowId">The workflow id.</param>
		public WorkflowEventArgs( int workflowId ) 
			: this( workflowId, false )
		{
			// Check Parameters
			ParamCode.AssertRange( workflowId, 1, int.MaxValue, "workflowId" );
		}

		/// <summary>
		/// Gets the workflow id.
		/// </summary>
		/// <value>The workflow id.</value>
		public int WorkflowId
		{
			get
			{
				return m_workflowId;
			}
		}

		/// <summary>
		/// Gets a value indicating whether the event is delivered only 
		/// listeners on the current state object or the workflow object.
		/// </summary>
		/// <value>
		/// 	<c>true</c> if deliver to current state only; otherwise delive to all listeners, <c>false</c>.
		/// </value>
		public bool DeliverToCurrentStateOnly
		{
			get
			{
				return m_deliverCurrentState;
			}
		}
			
	}
}
